\section{Building a Standalone Application}

\textbf{Sparkling Water Example Project}

This is a structure of a simple example project to start coding with Sparkling Water. The source code is available at
\url{https://github.com/h2oai/h2o-droplets/tree/master/sparkling-water-droplet}

\textbf{Project structure}

% Lots of code to draw a basic file structure, examples exist to jazz this up
\begin{forest}
  for tree={
    %font=\ttfamily,
    grow'=0,
    child anchor=west,
    parent anchor=south,
    anchor=west,
    calign=first,
    edge path={
      \noexpand\path [draw, \forestoption{edge}]
      (!u.south west) +(7.5pt,0) |- node[fill,inner sep=1.25pt] {} (.child anchor)\forestoption{edge label};
    },
    before typesetting nodes={
      if n=1
        {insert before={[,phantom]}}
        {}
    },
    fit=band,
    before computing xy={l=15pt},
  }
[
  [\texttt{gradle/} ........ Gradle definition files]
  [\texttt{src/} .............. Source code
    [\texttt{main/} ....... Main implementation code
      [\texttt{scala/} ]
    ]
    [\texttt{test/} ....... Test code
      [\texttt{scala/}]
    ]
  ]
  [\texttt{build.gradle} ... Build file for this project]
  [\texttt{gradlew} ........ Gradle wrapper]
]
\end{forest}

\textbf{Project building}

For building, please, use provided gradlew command:

\begin{lstlisting}[style=Bash]
./gradlew build
\end{lstlisting}

\textbf{Run demo}

For running a simple application:

\begin{lstlisting}[style=Bash]
./gradlew run
\end{lstlisting}

\textbf{Running tests}

To run tests, please, run:

\begin{lstlisting}[style=Bash]
./gradlew test
\end{lstlisting}

\textbf{Checking code style}

To check codestyle:

\begin{lstlisting}[style=Bash]
./gradlew scalaStyle
\end{lstlisting}

\textbf{Creating and Running Spark Application}

Create application assembly which can be directly submitted to Spark cluster:

\begin{lstlisting}[style=Bash]
./gradlew shadowJar
\end{lstlisting}

The command creates jar file \texttt{build/libs/sparkling-water-droplet-}\\
\texttt{app.jar} containing all necessary classes to run application on top of Spark cluster.

Submit application to Spark cluster (in this case, local cluster is used):

\begin{lstlisting}[style=Bash]
export MASTER="local[*]"
$SPARK_HOME/bin/spark-submit --class water.droplets.SparklingWaterDroplet build/libs/sparkling-water-droplet-all.jar
\end{lstlisting}


